# test/redis/conftest.py
"""
redis的测试环境配置
"""

import pytest
from dao.redis_connect import RedisClient


@pytest.fixture(scope="session")
def redis_client():
    """
    获取Redis客户端实例的fixture
    """
    client = RedisClient.get_client()
    yield client
    # 测试结束后清理数据
    client.flushdb()
    RedisClient.close()


@pytest.fixture(autouse=True)
def clean_redis(redis_client):
    """
    每个测试用例执行前清理Redis数据的fixture
    """
    yield
    redis_client.flushdb()
